package helo;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;

public class DynamicProxyTest {
	public static void main(String[] argv) throws Exception {
		try {
			ServiceFactory factory = ServiceFactory.newInstance();
			// Lookup Service. . Service is entry point for a web service.
			Service service = factory.createService(new URL(
					"http://localhost:8080/myws/HelloWorld?wsdl"), new QName(
					"http://webservices.samples.jboss.org/", "HelloWorldService"));
			// A webservice can have different port. Port is like a library of
			// methods.
			// Set the location of wsdl.
			IBonjour helloInterface = (IBonjour) service.getPort(new QName(
					"http://webservices.samples.jboss.org/", "HelloWorldPort"), IBonjour.class);
			// Invoke and Print the result.
			System.out.println(helloInterface.sayHello("barfoo"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}